Skip to content

feat: pass songs param from Slack bot to content creation#378

Merged
sweetmantech merged 6 commits intotestfrom
feature/REC-38-slack-songs-param
Mar 30, 2026
Merged

feat: pass songs param from Slack bot to content creation#378
sweetmantech merged 6 commits intotestfrom
feature/REC-38-slack-songs-param

Conversation

@recoup-coding-agent
Copy link
Copy Markdown
Collaborator

@recoup-coding-agent recoup-coding-agent commented Mar 30, 2026

Summary

  • Adds songs field to the AI prompt parser schema (contentPromptFlagsSchema) so the agent extracts song names from natural-language Slack mentions
  • Passes extracted songs array from registerOnNewMention handler through to triggerCreateContent payload
  • When a user says "make a lipsync video for the hiccups song", the songs array is now included in the API request

Test plan

  • Added test: parseContentPrompt extracts songs when mentioned in prompt
  • Added test: parseContentPrompt returns undefined songs when not mentioned
  • Added test: registerOnNewMention passes songs to triggerCreateContent
  • Added test: registerOnNewMention omits songs when not specified
  • All 29 tests pass
  • Manual: tag the content bot in Slack with "make a lipsync video for the hiccups song" and verify the songs array appears in the Trigger.dev task payload

Closes REC-38

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Content prompts now accept optional song entries so users can mention song names in their requests.
  • Refactor

    • Caption-length options centralized into a shared constant to ensure consistent "short/medium/long" choices across the app.
  • Validation

    • Song input validation improved: provided song entries must be non-empty strings; the field can still be omitted.

The AI prompt parser now extracts song names from natural-language
Slack mentions (e.g. "make a lipsync video for the hiccups song") and
forwards them to triggerCreateContent so the pipeline filters to the
requested songs.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Mar 30, 2026 11:38pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Warning

Rate limit exceeded

@sweetmantech has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 0 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 10 minutes and 0 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de9eb72b-0786-4942-b011-3aa38ccba3dc

📥 Commits

Reviewing files that changed from the base of the PR and between 678803a and 4970281.

⛔ Files ignored due to path filters (1)
  • lib/agents/content/__tests__/registerOnNewMention.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (2)
  • lib/agents/content/handlers/registerOnNewMention.ts
  • lib/content/validateCreateContentBody.ts
📝 Walkthrough

Walkthrough

Added an optional songs field to content prompt validation and threaded it from parsing through the mention handler into the content creation payload; extracted caption length literals into a shared CAPTION_LENGTHS constant.

Changes

Cohort / File(s) Summary
Schema & Flags
lib/agents/content/createContentPromptAgent.ts, lib/content/songsSchema.ts
Extended exported contentPromptFlagsSchema to include an optional songs field (uses songsSchema) and switched captionLength to z.enum(CAPTION_LENGTHS). Added songsSchema as z.array(z.string().min(1)).optional().
Validation Constants
lib/content/captionLengths.ts, lib/content/validateCreateContentBody.ts
Introduced CAPTION_LENGTHS constant (`"short"
Handler Integration
lib/agents/content/handlers/registerOnNewMention.ts
Destructures songs from parsed flags and conditionally includes songs in the triggerCreateContent payload when present and non-empty.

Sequence Diagram(s)

sequenceDiagram
  participant Mention as MentionEvent
  participant Parser as parseContentPrompt
  participant Handler as registerOnNewMention
  participant Creator as triggerCreateContent
  rect rgba(200,220,255,0.5)
    Mention->>Parser: deliver mention text
    Parser-->>Handler: flags {lipsync, batch, captionLength, songs?, ...}
    Handler->>Creator: payload {flags..., songs?}
    Creator->>Creator: create content job (persist/queue)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🎶 A tiny field, a gentle tune,
From prompt to job it sails by noon.
Enums refined, and schema sings,
Songs stitch through content-making things. ✨

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Solid & Clean Code ✅ Passed PR demonstrates excellent adherence to SOLID principles and clean code practices through DRY implementation extracting shared schemas/constants, clear SRP with focused modules, and proper composition-based extension without modifying existing code.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/REC-38-slack-songs-param

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/agents/content/createContentPromptAgent.ts`:
- Around line 33-38: Update the "songs" Zod schema so that if provided it cannot
be an empty array and each string is trimmed: change songs from
z.array(z.string().min(1)).optional() to
z.array(z.string().trim().min(1)).min(1).optional() (preserving the existing
.describe text); this enforces non-empty, trimmed song strings at the schema
level and aligns with the downstream check that expects a non-empty songs array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4857311a-63d6-4948-8659-ee7d77b35ee5

📥 Commits

Reviewing files that changed from the base of the PR and between 5961b30 and 2bc831d.

⛔ Files ignored due to path filters (2)
  • lib/agents/content/__tests__/parseContentPrompt.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/agents/content/__tests__/registerOnNewMention.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (2)
  • lib/agents/content/createContentPromptAgent.ts
  • lib/agents/content/handlers/registerOnNewMention.ts

Both validateCreateContentBody and createContentPromptAgent now
import from a single songsSchema definition. Validation rules
only need to change in one place.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Moves CAPTION_LENGTHS to lib/content/captionLengths.ts so both
validateCreateContentBody and createContentPromptAgent share the
same source of truth. Re-exported from validateCreateContentBody
for backward compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/content/validateCreateContentBody.ts (1)

14-16: Keep this validation module single-purpose by removing CAPTION_LENGTHS re-export.

Line 16 makes this file act as a constants barrel in addition to request validation. Prefer importing CAPTION_LENGTHS directly from @/lib/content/captionLengths in consumers.

♻️ Suggested minimal change
 import { CAPTION_LENGTHS } from "@/lib/content/captionLengths";
-
-export { CAPTION_LENGTHS };

As per coding guidelines, lib/**/*.ts should "Apply Single Responsibility Principle (SRP): one exported function per file; each file should do one thing well".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/content/validateCreateContentBody.ts` around lines 14 - 16, Remove the
CAPTION_LENGTHS re-export from this validation module so it only handles request
validation: delete the line exporting CAPTION_LENGTHS from
validateCreateContentBody.ts and update any consumers to import CAPTION_LENGTHS
directly from "@/lib/content/captionLengths"; ensure the validation functions
(e.g., the exported validator in validateCreateContentBody.ts) remain unchanged
and the file no longer serves as a constants barrel.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/content/validateCreateContentBody.ts`:
- Around line 14-16: Remove the CAPTION_LENGTHS re-export from this validation
module so it only handles request validation: delete the line exporting
CAPTION_LENGTHS from validateCreateContentBody.ts and update any consumers to
import CAPTION_LENGTHS directly from "@/lib/content/captionLengths"; ensure the
validation functions (e.g., the exported validator in
validateCreateContentBody.ts) remain unchanged and the file no longer serves as
a constants barrel.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db375f6f-af74-4068-bd88-16d7df51aec3

📥 Commits

Reviewing files that changed from the base of the PR and between 2bc831d and 678803a.

⛔ Files ignored due to path filters (2)
  • lib/content/__tests__/captionLengths.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/content/__tests__/songsSchema.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (4)
  • lib/agents/content/createContentPromptAgent.ts
  • lib/content/captionLengths.ts
  • lib/content/songsSchema.ts
  • lib/content/validateCreateContentBody.ts
✅ Files skipped from review due to trivial changes (2)
  • lib/content/songsSchema.ts
  • lib/content/captionLengths.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/agents/content/createContentPromptAgent.ts

Comment on lines +14 to +16
import { CAPTION_LENGTHS } from "@/lib/content/captionLengths";

export { CAPTION_LENGTHS };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this export needed?

Nothing imports CAPTION_LENGTHS from validateCreateContentBody —
the re-export was YAGNI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When songs are specified, the ack message now shows which songs
will be used (e.g. "using hiccups, adhd").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use Slack-compatible markdown (*bold* not **bold**) and bullet
list for details including song names, template, lipsync, and
video count.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sweetmantech sweetmantech merged commit 3f5ba28 into test Mar 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants